package com.shensi.appCollect.enums;

import java.util.HashMap;

public enum CardTypeEnum {

    CARD_OILS_TYPE_COMMON("0","通用会员卡"),
    CARD_OILS_TYPE_GASOLINE("1","汽油会员卡"),
    CARD_OILS_TYPE_DIESEL("2","柴油会员卡"),
    CARD_OILS_TYPE_LNG("3","LNG会员卡"),
    CARD_OILS_TYPE_CNG("4","CNG会员卡");

    private String value;
    private String text;

    CardTypeEnum(String value, String text) {
        this.value = value;
        this.text = text;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }


    private static HashMap<String, CardTypeEnum> keyMap;

    public static CardTypeEnum getByValue(String key){
        if (keyMap == null) {
            HashMap<String, CardTypeEnum> map = new HashMap<>();
            for (CardTypeEnum value : CardTypeEnum.values()) {
                map.put(value.getValue(),value);
            }
            keyMap = map;
        }
        return keyMap.get(key);
    }

    public static CardTypeEnum getByValue(String key,CardTypeEnum recordType){
        CardTypeEnum type = getByValue(key);
        return type == null ? recordType : type;
    }

}